home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: Philippe Verdy <100105.3120@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: C++ Read Comma Delimted Text File
- Date: 7 Apr 1996 22:56:51 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4k9h7j$fl9@arl-news-svc-5.compuserve.com>
- NNTP-Posting-Host: ad04-110.compuserve.com
-
- Steve Farson <75226.1623@CompuServe.COM> s'Θcrit :
- > I've never seen or heard of any example showing how to read a
- > comma delimted text file looking something like this:
- >
- > ABC,13,12.3,Houston
- > DEF,4,11.4,Denver
- > EFG,21,14.7,Phoenix
- >
- > into variables. I have a C program doing this, but think there
- > surely is some C++ functions that can help here. Someone
- > mentioned Getline() once, but every reference I have says nothing
- > about how it would/could be used. If anyone could provide a
- > snippet or two on how this is done, it would be great.
- >
- > Thanks! Steve
-
- Coming from Borland C++ 5.0 Help file:
- --------------------------------------
- istream::get
-
- Syntax
-
- Form 1 int get();
- Form 2 istream& get(char*, int len, char = '\n');
- istream& get(signed char*, int len, char = '\n');
- istream& get(unsigned char*, int len, char = '\n')
- Form 3 istream& get(char&);
- istream& get(signed char&);
- istream& get(unsigned char&);
- Form 4 istream& get(streambuf&, char = '\n');
-
- Description
-
- Form 1: Extracts the next character or EOF.
- Form 2: Extracts characters into the given char * until the
- delimiter (third parameter) or end-of-file is
- encountered, or until (len - 1) bytes have been read.
- A terminating null is always placed in the output
- string. The delimiter is not extracted from the input
- stream. Fails only if no characters were extracted.
- Form 3: Extracts a single character into the given character
- reference.
- Form 4: Extracts characters into the given streambuf until
- the delimiter is encountered.
- ----------------
- istream::ignore
-
- Syntax
-
- istream& ignore(int n = 1, int delim = EOF);
-
- Description
-
- The ignore member function causes up to n characters in the
- input stream to be skipped; stops if delim is encountered.
- The deliminator is extracted from the stream.
- -----------------
- istream::get(), istream::getline(), and istream::read()
- perform unformatted input from the istream.
-